<?php
namespace app\admin\model;

use think\Model;

class Script extends Model
{   
	/*查询数据 */
	public function get_data(){
        $data=Script::where([['status','=',1]])->select()->order('create_time','desc');
        return $data;
	}
	/*新增*/
	public function insert_data($title,$content,$site){
        $Script = new Script;
		$result=$Script->save([
		    'title'  =>  trim($title),
		    'content' =>  trim($content),
		    'site' =>  trim($site),
		]);
		return $result;
	}
	/*修改*/
	public function update_data($id,$title,$content,$site){
        $data = Script::get($id);
        $data->title = $title;
        $data->content = $content;
        $data->site = $site;
        $result=$data->save();
		return $result;    
	}
	/*删除假动作实际为修改操作*/
	public function delete_data($id){
        $data = Script::get($id);
        if($data['status']!=1){
        	$result=['status'=>'0','msg'=>'无需操作'];
	        return json($result);
        }
		$data->status = '2';
		$result=$data->save();
		return $result;
	}
}
 